package com.ruoyi.system.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SupplierTransaction;
import com.ruoyi.system.service.ISupplierTransactionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
 * 供应商账户流水Controller
 * 
 * @author ruoyi
 * @date 2024-12-14
 */
@RestController
@RequestMapping("/wms/transaction")
public class SupplierTransactionController extends BaseController
{
    @Autowired
    private ISupplierTransactionService supplierTransactionService;
    /**
     * 查询供应商账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('wms:transaction:list')")
    @GetMapping("/list")
    public TableDataInfo list(SupplierTransaction supplierTransaction)
    {
        startPage();
        List<Map<String,Object>> list = supplierTransactionService.selectSupplierTransactionList(supplierTransaction);
        System.out.println(list);
        return getDataTable(list);
    }

    /**
     * 获取供应商账户流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:transaction:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(supplierTransactionService.selectSupplierTransactionById(id));
    }
    /**
     * 新增供应商账户流水
     */
    @PreAuthorize("@ss.hasPermi('wms:transaction:add')")
    @Log(title = "供应商账户流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SupplierTransaction supplierTransaction)
    {
        return toAjax(supplierTransactionService.insertSupplierTransaction(supplierTransaction));
    }

    /**
     * 修改供应商账户流水
     */
    @PreAuthorize("@ss.hasPermi('wms:transaction:edit')")
    @Log(title = "供应商账户流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SupplierTransaction supplierTransaction)
    {
        return toAjax(supplierTransactionService.updateSupplierTransaction(supplierTransaction));
    }
    /**
     * 删除供应商账户流水
     */
    @PreAuthorize("@ss.hasPermi('wms:transaction:remove')")
    @Log(title = "供应商账户流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(supplierTransactionService.deleteSupplierTransactionByIds(ids));
    }

    /**
     * 根据供应商账号流水的交易编号查询单条数据
     * @param id
     * @return
     */
    @PreAuthorize("@ss.hasPermi('wms:supplierTransaction:query')")
    @GetMapping(value = "/select/{Code}")
    public AjaxResult selectSupplierTransactionByCodeID(@PathVariable("Code") String id)
    {
        return success(supplierTransactionService.selectSupplierTransactionByCodeID(id));
    }



}
